Using Pandas/Numpy, I took the inverse of a matrix as follows:
A = D.dot(B) # 'D' is 234x462 and 'B' is 462x234 I = np.identity(234) # Identity matrix that is 234x234 step_1 = I - A squared = inv(step_1)
Before I did anything, I had to manually fill empty cells in the 'D' matrix with zeros. After that, everything worked fine and I got the results I expected. However, I have a very large number of similar computations to perform and, as you can imagine, I don't want to manually fill empty cells in my dataframes every time I am performing a matrix inversion. With that in mind, I used the fillna method as follows:
D = D.fillna(0)
This filled the empty cells with zeros and everything looked fine but when I try to do the matrix inversion (as above), I get an error message: "LinAlgError: Singular matrix." Any ideas/suggestions? Thanks!
You must be logged in to post. Please login or register an account.